<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
        <meta name="format-detection" content="telephone=no">
        <meta name="applicable-device" content="mobile">
        <title>大件会</title>
        <link rel="stylesheet" type="text/css" href="../lib/layer/theme/default/layer.css">
        <link rel="stylesheet" type="text/css" href="../css/activity.css">
    </head>

    <body>
        <div class="rewardContainer">
            <div class="content">
                <div>感谢您参与</div>
                <div>“维达Emoji限量版手帕纸”</div>
                <div class="portrit">
                    <!-- <div class="hasJoin">
                    <img src="../images/award/header_t.png" alt="">
                    <p>大件君</p>
                </div>
                <div class="hasJoin noJoin">
                    <img src="../images/award/wenhaotouxiang_big.png" alt="">
                    <p></p>
                </div>
                <div class="hasJoin noJoin">
                    <img src="../images/award/wenhaotouxiang_big.png" alt="">
                    <p></p>
                </div> -->
                </div>

                <!-- <div class="token"></div> -->

                <div class="otherzhuli">好友正在助力中，当前进度
                    <span class="perRatio">1/3</span>
                </div>
                <div class="zhuliBtn">
                    <div class="btn" id="againBtn">再次邀请</div>
                </div>
            </div>
            <!--分享-->
            <div class="homeShare">
                <img src="../images/share/share_.png" onclick="closeModel();" />
                <img src="../images/share/i_know.png" class="close" onclick="closeModel();" />
            </div>
        </div>
    </body>
    <script src="../js/jquery-1.11.3.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="../lib/layer/layer.js"></script>
    <script src="../js/ajax.js"></script>
    <script src="../js/prompt.js"></script>
    <script src="../js/share.js"></script>
    <script type="text/javascript">
        /* 关闭弹窗 */
        function closeModel() {
            $('.homeShare').hide();
        }
        var ajaxStatus = true;
        $(function () {
            /* 从url里取键值对 */
            function getUrlString() {
                var urlStr = window.location.search;  //?sex=man&age=20
                if (urlStr != null && urlStr.toString().length > 1) {
                    var myUrlStr = urlStr.substr(1);  //sex=man&age=20
                    var array1 = myUrlStr.split("&");  //["sex=man"],["age=20"]
                    var getString = {};
                    for (var i = 0; i < array1.length; i++) {
                        getString[array1[i].split("=")[0]] = array1[i].split("=")[1]; //["sex","man"]["age","20"]
                    }
                    return getString;
                } else {
                    console.log("无参数");
                }
            }

            var gus = new getUrlString();
            console.log(gus.isopenPage, gus.openGroupId)
            var isopenPage = gus.isopenPage;
            //跳转的团长id
            var openGroupId = gus.openGroupId;
            //分享来的团长id
            var initiatorId = gus.initiatorId;
            var spreadId = gus.spreadId
            // alert("助力奖励链接"+window.location.href)
            var fromId = JSON.parse(localStorage.getItem("fromId"));
            // var spreadId = fromId.spreadId || ''
            // alert('第几次'+spreadId)
            // var spreadId = gus.spreadId
            // alert('开团id'+openGroupId)

            var token = localStorage.getItem("token");
            var type = 'post'
            var dataType = 'json'
            var zlListParams = {
                // token: '3572dbf39923c3df029c263c884e7479',//userinfo.token'476230e27386384bb5330f9cc96eaaaa'没有成团token
                token: token,//userinfo.token'476230e27386384bb5330f9cc96eaaaa'
                loginType: 51,//userinfo.loginType 50-本地会员,51-第三方微信登录,52-第三方QQ登录
                // initiatorId: 11 //从分享链接获取 
                initiatorId: openGroupId //从分享链接获取
            }
            //判断能否助力
            // var myself = false
            var urlAbleHelp = url + "/api/activity/help/ableHelp";
            post(urlAbleHelp, zlListParams, sucAbleHelp, false, type, dataType);
            function sucAbleHelp(data) {
                // alert('能否助力:' + JSON.stringify(data))
                if (data.code == 200) {
                    //老会员按钮置灰和弹窗
                    // if (data.obj.ableHelp == 1 && data.obj.reason == 'helpYourselfGroup') {
                    if (data.obj.ableHelp == 1 && data.obj.reason == 'repeatHelp') {
                        // myself = true
                        var isktdatas = {
                            // token: '476230e27386384bb5330f9cc96eaaaa',//userinfo.token'476230e27386384bb5330f9cc96eaaaa'
                            token: token,//userinfo.token'476230e27386384bb5330f9cc96eaaaa'
                            loginType: 51,//userinfo.loginType 50-本地会员,51-第三方微信登录,52-第三方QQ登录
                        }
                        //是否已经开团过
                        var urlIsOpenGroup = url + "/api/activity/initiator/isOpenGroup";
                        post(urlIsOpenGroup, isktdatas, sucIsOpenGroup, false, type, dataType);
                        function sucIsOpenGroup(data) {
                            // alert('能否开团:' + JSON.stringify(data))
                            if (data.code == 200) {
                                var isOpenGroup = data.obj.isOpenGroup;
                                // alert('isOpenGroup:' + JSON.stringify(isOpenGroup));
                                // alert("团长id:" + data.obj.initiatorId)
                                if (isOpenGroup == 1) {//0没有开团  1 已经开团
                                    zlListParams.initiatorId = data.obj.initiatorId
                                    // alert('加自己'+ zlListParams.initiatorId)
                                    //window.location.href = '../pages/reward.html?isopenPage=' + isopenPage + '&openGroupId=' + openGroupId + '&token=' + tokenPass + '&spreadId=' + spreadId
                                }
                            }
                        }
                    }
                }
            }

            /* $.ajax({
                type: "post",
                url: url + "/api/activity/help/ableHelp",
                data: zlListParams,
                async: false,
                success: function (data) {
                    console.log(data)
                    // alert('能否助力:' + JSON.stringify(data));
                    if (data.code == 200) {
                        //老会员按钮置灰和弹窗
                        // if (data.obj.ableHelp == 1 && data.obj.reason == 'helpYourselfGroup') {
                        if (data.obj.ableHelp == 1 && data.obj.reason == 'repeatHelp') {
                            // myself = true
                            var isktdatas = {
                                // token: '476230e27386384bb5330f9cc96eaaaa',//userinfo.token'476230e27386384bb5330f9cc96eaaaa'
                                token: token,//userinfo.token'476230e27386384bb5330f9cc96eaaaa'
                                loginType: 51,//userinfo.loginType 50-本地会员,51-第三方微信登录,52-第三方QQ登录
                            }
                            $.ajax({
                                type: "post",
                                url: url + "/api/activity/initiator/isOpenGroup",
                                async: false,
                                data: isktdatas,
                                success: function (data) {
                                    // alert('是否开团:' + JSON.stringify(data));
                                    if (data.code == 200) {
                                        var isOpenGroup = data.obj.isOpenGroup;
                                        // alert('isOpenGroup:' + JSON.stringify(isOpenGroup));
                                        // alert("团长id:" + data.obj.initiatorId)
                                        if (isOpenGroup == 1) {//0没有开团  1 已经开团
                                            zlListParams.initiatorId = data.obj.initiatorId
                                            // alert('加自己'+ zlListParams.initiatorId)
                                            //window.location.href = '../pages/reward.html?isopenPage=' + isopenPage + '&openGroupId=' + openGroupId + '&token=' + tokenPass + '&spreadId=' + spreadId
                                        }
                                    }
                                },
                                error: function () {
    
                                }
                            });
                        } else {
                            // myself = false
                        }
                    }
                },
                error: function () {
                    // alert('不能助力:')
                }
            }); */


            // }
            /* 第一次从邀请好友页面分享过来后的第二次分享进来的页面跳转到助力一把页面 */
            openGroupId = zlListParams.initiatorId
            if (isopenPage == 0) {
                window.location.href = './lxIndex.html?isopenPage=0&initiatorId=' + initiatorId + '&spreadId=' + spreadId
            }

            if (isopenPage != 0 || isopenPage == '') {
                isopenPage = 1
                // alert(isopenPage)
            }
            /* var token = gus.token;
            localStorage.setItem('token',token);
            token = localStorage.getItem("token"); */
            // alert(token)
            // $(".token").html(token);
            /* 请求助力人列表 */
            var urlHelpList = url + "/api/activity/help/helpList";
            post(urlHelpList, zlListParams, sucHelpList, false, type, dataType);
            function sucHelpList(res) {
                alert('助力人列表' + JSON.stringify(zlListParams))
                if (res.code == 200) {
                    var VoList = res.obj.activityHelpVoList
                    res.obj.activityHelpVoList.forEach(function (item, i) {
                        // console.log(item)
                        $('.portrit').append('<div class="hasJoin hasJoin' + i + '"><img src="' + (item.avatar ? item.avatar : '../images/award/header_t.png') + '">\n' +
                            '<p>' + (item.nickName ? item.nickName : '') + '</p></div >')
                    })
                    $(".perRatio").html(res.obj.activityHelpVoList.length + "/3");
                    if (res.obj.activityHelpVoList.length < 3) {
                        if (res.obj.activityHelpVoList.length == 1) {
                            $(".portrit .hasJoin0").after('<div class="hasJoin"><img src="../images/award/wenhaotouxiang_big.png">\n' +
                                '<p></p></div><div class="hasJoin"><img src="../images/award/wenhaotouxiang_big.png">\n' +
                                '<p></p></div>');
                        }
                        else if (res.obj.activityHelpVoList.length == 2) {
                            $(".portrit .hasJoin1").after('<div class="hasJoin"><img src="../images/award/wenhaotouxiang_big.png">\n' +
                                '<p></p></div>');
                        }
                    }
                    if (res.obj.activityHelpVoList.length >= 3) {
                        $(".perRatio").html("3/3");
                    }
                    //判断是否是本人点开成团分享
                    if (res.obj.activityHelpVoList.length >= 3 && isopenPage != 0) {
                        window.location.href = "./attention.html";
                    }
                }
            }
            /* 请求助力人列表 */
            /* $.ajax({
                type: "post",
                url: url + "/api/activity/help/helpList",
                data: zlListParams,
                async: false,
                success: function (res) {
                    // alert('他快'+JSON.stringify(zlListParams))
                    console.log(res)
                    if (res.code == 200) {
                        var VoList = res.obj.activityHelpVoList
                        res.obj.activityHelpVoList.forEach(function (item, i) {
                            // console.log(item)
                            $('.portrit').append('<div class="hasJoin hasJoin' + i + '"><img src="' + (item.avatar ? item.avatar : '../images/award/header_t.png') + '">\n' +
                                '<p>' + (item.nickName ? item.nickName : '') + '</p></div >')
                        })
                        $(".perRatio").html(res.obj.activityHelpVoList.length + "/3");
                        if (res.obj.activityHelpVoList.length < 3) {
                            if (res.obj.activityHelpVoList.length == 1) {
                                $(".portrit .hasJoin0").after('<div class="hasJoin"><img src="../images/award/wenhaotouxiang_big.png">\n' +
                                    '<p></p></div><div class="hasJoin"><img src="../images/award/wenhaotouxiang_big.png">\n' +
                                    '<p></p></div>');
                            }
                            else if (res.obj.activityHelpVoList.length == 2) {
                                $(".portrit .hasJoin1").after('<div class="hasJoin"><img src="../images/award/wenhaotouxiang_big.png">\n' +
                                    '<p></p></div>');
                            }
                        }
                        if (res.obj.activityHelpVoList.length >= 3) {
                            $(".perRatio").html("3/3");
                        }
                        //判断是否是本人点开成团分享
                        if (res.obj.activityHelpVoList.length >= 3 && isopenPage != 0) {
                            window.location.href = "./attention.html";
                        }
                    }

                }
            }) */

            /* 判断有无成团 */
            var urlIsSuccessGroup = url + "/api/activity/initiator/isSuccessGroup";
            post(urlIsSuccessGroup, zlListParams, sucIsSuccessGroup, true, type, dataType);
            function sucIsSuccessGroup(res) {
                // alert('有无成团:' + JSON.stringify(res))
                if (res.code == 200) {
                    if (res.obj.isSuccessGroup == 0) {
                        // 再次邀请
                        // whether4('<div class="title">您还需要再次邀请</div>', '我知道了')
                        // alert('奖励跳'+isopenPage, initiatorId)
                        $('#againBtn').click(function () {
                            $('.homeShare').show();
                            // window.location.href = './lxIndex.html?isopenPage='+ isopenPage+'&initiatorId=' + initiatorId
                            // window.location.href="lxIndex.html?againId=2";
                            var signUrl = window.location.href.split('#');
                            var signUrl2 = signUrl + '&isopenPage=0&initiatorId=' + openGroupId + '&spreadId=' + spreadId;
                            console.log('signUrl是' + signUrl)
                            var urlSdk = url + "/api/js/sdk";
                            var sdkParams = { signUrl: encodeURIComponent(signUrl)}
                            // alert('要请函数'+ JSON.stringify(sucSdk))
                            post(urlSdk, sdkParams, sucSdk, true, type, dataType, errSdk);
                            function sucSdk(data) {
                                var code = data.code;
                                var jsSdk = data.obj.jsSdk;
                                // alert('jsSdk' + JSON.stringify(jsSdk));
                                if (code == 200) {
                                    // alert('jsSdk' + JSON.stringify(jsSdk))
                                    share(jsSdk, signUrl2, '100%可得维达Emoji限量版手帕纸免费送', '100%可得维达Emoji限量版手帕纸免费送', 'http://zjevent47.dajianhui.com/images/dajianLogo.png', isopenPage, openGroupId, token, spreadId);
                                }
                            }
                            function errSdk(data) {
                                alert('分享失败');
                            }
                        })
                    }
                }
            }
           
            /* $.ajax({
                type: "post",
                url: url + "/api/activity/initiator/isSuccessGroup",
                // data: isktdatas,
                data: zlListParams,
                async: true,
                success: function (res) {
                    // alert('有无成团:'+ JSON.stringify(res))
                    if (res.code == 200) {
                        if (res.obj.isSuccessGroup == 0) {
                            // 再次邀请
                            // whether4('<div class="title">您还需要再次邀请</div>', '我知道了')
                            // alert('奖励跳'+isopenPage, initiatorId)
                            $('#againBtn').click(function () {
                                $('.homeShare').show();
                                // window.location.href = './lxIndex.html?isopenPage='+ isopenPage+'&initiatorId=' + initiatorId
                                // window.location.href="lxIndex.html?againId=2";
                                var signUrl = window.location.href.split('#');
                                var signUrl2 = signUrl + '&isopenPage=0&initiatorId=' + openGroupId + '&spreadId=' + spreadId;
                                console.log('signUrl是' + signUrl)
                                $.ajax({
                                    type: "post",
                                    url: url + "/api/js/sdk",
                                    data: {
                                        signUrl: encodeURIComponent(signUrl)
                                    },
                                    async: true,
                                    success: function (data) {
                                        var code = data.code;
                                        var jsSdk = data.obj.jsSdk;
                                        if (code == 200) {
                                            // alert('jsSdk' + JSON.stringify(jsSdk))
                                            share(jsSdk, signUrl2, '100%可得维达Emoji限量版手帕纸免费送', '100%可得维达Emoji限量版手帕纸免费送', 'http://zjevent47.dajianhui.com/images/dajianLogo.png', isopenPage, openGroupId, token, spreadId);
                                        }
                                    },
                                    error: function (data) {
                                        alert(data.msg);
                                        console.log(data);
                                    }
                                });
                            })
                        } else {
                            // window.location.href = './attention.html';
                        }
                    }
                }
            }) */

        })
    </script>

</html>